package com.zj.study.handle;

import com.zj.study.pojo.FinalResultVO;
import com.zj.study.pojo.RespStatusEnum;
import org.springframework.http.ResponseEntity;
import org.springframework.web.server.ServerWebInputException;

public class ServerWebInputExceptionHandler implements ExceptionHandler {

  @Override
  public boolean match(Class<?> clazz) {
    return ServerWebInputException.class == clazz;
  }

  @Override
  public ResponseEntity<?> handler(Throwable throwException) {
    return ResponseEntity
        .badRequest()
        .body(FinalResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS));
  }
}